package c.x.jy.wexin.controller;

import c.x.jy.common.utils.PageUtils;
import c.x.jy.common.utils.R;
import c.x.jy.dao.entity.ContactusEntity;
import c.x.jy.service.service.ContactusService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 
 *
 * @author amwhyh
 * @email xxx@xx.com
 * @date 2021-06-17 17:35:55
 */
@RestController
@RequestMapping("wechat/contactus")
public class ContactusController {
    @Autowired
    private ContactusService contactusService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:contactus:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = contactusService.queryPage(params);

        return R.put(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:contactus:info")
    public R info(@PathVariable("id") Long id){
		ContactusEntity contactus = contactusService.getById(id);

        return R.put(contactus);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ContactusEntity contactus){
		contactusService.save(contactus);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:contactus:update")
    public R update(@RequestBody ContactusEntity contactus){
		contactusService.updateById(contactus);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("sys:contactus:delete")
    public R delete(@PathVariable("id") Long id){
		contactusService.removeByIds(Arrays.asList(id));

        return R.ok();
    }

}

